<template>
  <div class="app-container">

    <el-form :model="selectForm" ref="selectForm" :inline="true">
      <el-form-item label="出库单号">
        <el-input
          v-model="selectForm.outboundCode"
          placeholder="请输入出库单号"
          clearable
          size="small"
          @keyup.enter.native="getList"
        />
      </el-form-item>
      <el-form-item label="领料部门">
        <el-input
          v-model="selectForm.recipientsDepartmentName"
          placeholder="请输入领料部门"
          clearable
          size="small"
          @keyup.enter.native="getList"
        />
      </el-form-item>
    </el-form>
    <el-form :model="selectForm" ref="selectForm" :inline="true" label-width="120px">
      <el-form-item>
        <el-button size="mini" type="primary" icon="el-icon-search" @click="getList">搜索</el-button>
        <!--        <el-button size="mini" type="success" icon="el-icon-plus" @click="add"-->
        <!--                   v-hasPermi="['system:brandInformation:add']">新增-->
        <!--        </el-button>-->
      </el-form-item>
    </el-form>


    <el-table :data="list.rows" border v-loading="loading">
      <el-table-column align="center" type="index" label="序号" width="55"/>
      <el-table-column label="出库单号" prop="outboundCode" align="center" width="150px">
        <template slot-scope="scope" style="text-align: center">
          <el-button size="mini" type="text" @click="details(scope.row)" v-hasPermi="['purchaseGL:cgju:details']">
            {{ scope.row.outboundCode }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="领用标题" prop="borrowRecordTitle" align="center" width="300px"/>
      <el-table-column label="领料部门" prop="recipientsDepartmentName" align="center" width="100px"/>
      <el-table-column label="发料仓库名称" prop="warehouseName" align="center"/>
      <el-table-column label="领料日期" prop="acquisitionDate" align="center" :show-overflow-tooltip="true"/>
      <el-table-column label="物资主管" prop="materialsSupervisorName" align="center"/>
      <el-table-column label="业务部门" prop="operatingDepartmentName" align="center" :show-overflow-tooltip="true"/>
      <el-table-column label="领用主管" prop="directorRecipientsName" align="center"></el-table-column>
      <el-table-column label="领料员" prop="receiptorName" align="center"/>
      <el-table-column label="仓库管理员" prop="warehouseKeeper" align="center" :show-overflow-tooltip="true"/>
      <el-table-column label="实际发放数量" prop="actualQuantityIssued" align="center"></el-table-column>
      <el-table-column label="计划金额" prop="planMoney" align="center"/>

      <el-table-column label="操作" align="center" fixed="right" width="200px">
        <template slot-scope="scope">
          <!--          <el-button size="mini" type="success" icon="el-icon-edit" @click="edit(scope.row)"-->
          <!--                     v-hasPermi="['system:brandInformation:edit']">修改-->
          <!--          </el-button>-->
          <el-button size="mini" type="danger" icon="el-icon-delete" @click="del(scope.row)"
                     v-hasPermi="['system:brandInformation:delete']">删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      :total="list.total?list.total:0"
      :page.sync="selectForm.pageNum"
      :limit.sync="selectForm.pageSize"
      @pagination="getList"
    />

    <spare-parts-borrow-record-detail v-if="isprocureDes" @subSetChane="subSetChane"
                                      :pid="pid"></spare-parts-borrow-record-detail>

  </div>
</template>

<script>
import {list,del} from "@/api/sparePartsBorrowRecord/index"
import sparePartsBorrowRecordDetail from '@/views/sparePartsBorrowRecord/detail'

export default {
  name: "index",
  data() {
    return {
      list: {},
      //领用记录入参
      selectForm: {
        outboundCode: '',
        recipientsDepartmentName: '',
        pageNum: 1,
        pageSize: 10,
      },
      isprocureDes: false,
      pid: null,
      loading: false,
    }
  },
  components: {
    sparePartsBorrowRecordDetail,
  },
  created() {
    this.getList();
  },
  methods: {
    async getList() {
      let row = await list(this.selectForm);
      this.list = row;
    },
    //查看详细
    details(row) {
      this.pid = row.id
      this.isprocureDes = true
    },
    //关闭查看详细信息
    subSetChane() {
      this.isprocureDes = false
      this.pid = null
    },
    del(row) {
      this.$confirm('确定删除吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        await del(row.id);
        this.$message.success('删除成功');
        await this.getList();
      }).catch(() => {
        this.$message.info('取消删除')
      });
    },
  }
}
</script>

<style scoped>

</style>
